home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9103 / lastlog / isequiv.c < prev    next >
C/C++ Source or Header  |  1991-01-20  |  2KB  |  67 lines

  1. /*****************************************************************
  2. *  IsEquiv.C
  3. *  written by Kathy Cea, Platinum Software Int'l
  4. *
  5. *  IsEquiv is a utility to check whether the user has a security
  6. *  equivalence to the specified user/group.  Designed to be used from a
  7. *  DOS batch file.
  8. *
  9. *  Calling Syntax:
  10. *     IsEquiv <user/group>
  11. *       <user/group> - The name of the user or group to be checked
  12. *
  13. *  Returns the following:
  14. *      0 - User has the security equivalence
  15. *      1 - No user/group name was supplied on the command line
  16. *      2 - User does not have the security equivalence
  17. *      3 - User/Group does not exist
  18. *      4 - Other error
  19. *
  20. *   Compiled in Turbo C 2.0 with NetWare C function calls
  21. *****************************************************************/
  22.  
  23. #include <stdio.h>
  24. #include <nit.h>
  25. #include <niterror.h>
  26.  
  27. WORD ConnectNumber;
  28. char objectName[48],secequiv[48];
  29. WORD objectType;
  30. long objectID;
  31. BYTE loginTime[7];
  32.  
  33.  
  34. main(int argc, char *argv[])
  35. {
  36.        if(argc < 2) {
  37.             printf("No Security Equivalence supplied\n");
  38.             exit(1);
  39.     }
  40.     strcpy(secequiv, argv[1]);
  41.  
  42.     /* Get the user's object name */
  43.     ConnectNumber =  GetConnectionNumber();
  44.     GetConnectionInformation(ConnectNumber, objectName,
  45.             &objectType, &objectID,loginTime);
  46.  
  47.     /* Check for a user equivalence */
  48.     if (IsBinderyObjectInSet(objectName, OT_USER,"SECURITY_EQUALS",
  49.             secequiv, OT_USER) == SUCCESSFUL) {
  50.             exit(0);
  51.         }
  52.     else
  53.     /* Check for a group equivalence */
  54.     switch (IsBinderyObjectInSet(objectName, OT_USER,"SECURITY_EQUALS",
  55.             secequiv, OT_USER_GROUP)){
  56.         case SUCCESSFUL:
  57.             exit(0);
  58.         case NO_SUCH_MEMBER:
  59.             exit(2);
  60.         case NO_SUCH_OBJECT:
  61.             exit(3);
  62.         default:
  63.             exit(4);
  64.         }
  65. }
  66.  
  67.